package com.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.project.domain.bo.VProjectMemberBo;
import com.project.domain.entity.zxProject.BizZxProjectMember;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProjectMembersMapper extends BaseMapper{

    /**
     * 获取成员列表(查的视图)
     * @param memBo 成员姓名
     * @return
     */
    @Select({
            "<script>",
            "select * from v_project_member vpm",
            "where 1=1 ",
            "<if test='memBo.personName != null and memBo.personName != \"\"'>",
            "and vpm.PERSON_NAME like CONCAT('%', CAST(#{memBo.personName} AS CHAR), '%') ",
            "</if>",
            "<if test='memBo.projectId != null and memBo.projectId != \"\"'>",
            "and vpm.PROJECT_ID = '${memBo.projectId}' ",
            "</if>",
            "<if test='memBo.personId != null and memBo.personId != \"\"'>",
            "and vpm.PERSON_ID = '${memBo.personId}' ",
            "</if>",
            "<if test='memBo.bearTypeId != null and memBo.bearTypeId != \"\"'>",
            "and vpm.BEAR_TYPE_ID in ('${memBo.bearTypeId}') ",
            "</if>",
            "order by vpm.ORDER_ID asc",
            "</script>"
    })
    List<BizZxProjectMember> getMemberList(@Param("memBo") VProjectMemberBo memBo);

    /**
     * 根据项目号删除成员
     * @param proId
     * @return
     */
    @Delete("delete from biz_yf_contract_member where CONTRACT_ID = '${proId}'")
    int delYFMembers(@Param("proId") String proId);
}
